<template>
  <div id="app">
    <el-container v-if="token">
      <el-header>
        深圳西部硅谷-千锋菜市场
        <el-button class="bn" @click="userLogin">登录</el-button>
      </el-header>

      <el-container>
        <el-aside width="200px">
          <el-menu
            default-active="2"
            class="el-menu-vertical-demo"
            router
            background-color="#545c64"
            text-color="#fff"
            active-text-color="#ffd04b"
          >
            <el-submenu index="1">
              <template slot="title">
                <i class="el-icon-location"></i>
                <span>概况
                </span>
              </template>
              <el-menu-item-group>
                <template slot="title">商品管理</template>
                <el-menu-item index="find">广告列表</el-menu-item>
                <el-menu-item index="good">商品管理</el-menu-item>
              </el-menu-item-group>
              <el-menu-item-group title="商品工具">
                <el-menu-item index="add">新增商品</el-menu-item>
                <el-menu-item index="quill">商品导入</el-menu-item>
                <el-menu-item index="filter">商品筛选</el-menu-item>
              </el-menu-item-group>
              <el-submenu index="1-4">
                <template slot="title">我要分销</template>
                <el-menu-item index="1-4-1">市场选货</el-menu-item>
              </el-submenu>
            </el-submenu>
            <el-menu-item index="2">
              <i class="el-icon-menu"></i>
              <span slot="title">店铺</span>
            </el-menu-item>
            <el-menu-item index="3" disabled>
              <i class="el-icon-document"></i>
              <span slot="title">商品</span>
            </el-menu-item>
            <el-menu-item index="4">
              <i class="el-icon-setting"></i>
              <span slot="title">订单</span>
            </el-menu-item>
          </el-menu>
        </el-aside>
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
    <div v-else>
      <Login></Login>
    </div>
  </div>
</template>

<script>
export default {
  name: "App",
  components: {
     Login: ()=> import('@/pages/Login.vue')
  },
  methods: {
    userLogin() {
      this.$router.push("/login");
      console.log(this.$route)
    }
  },
  data() {
      return {
        token : localStorage.getItem("token") 
      }
    },
};
</script>

<style>
* {
  margin: 0;
  padding: 0;
}
html,
body {
  width: 100%;
  height: 100%;
}
#app {
  width: 100%;
  height: 100%;
}
.home {
  width: 100%;
  height: 100%;
}
.el-container {
  width: 100%;
  height: 100%;
}
.el-header,
.el-footer {
  background-color: #b3c0d1;
  color: #333;
  text-align: center;
  line-height: 60px;
}

.el-aside {
  background-color: #d3dce6;
  color: #333;
  text-align: center;
  line-height: 200px;
}

.el-main {
  background-color: #e9eef3;
  color: #333;
}

body > .el-container {
  margin-bottom: 40px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}
.bn {
  position: absolute;
  right: 10px;
  top: 5px;
}
</style>
